import React, { Component } from 'react';
import {clearShopcart,shopcartlist} from '../../utils/api'
import {Toast} from 'antd-mobile'
class MyHeader extends Component {
        //清空购物车
        handleClear(){
            Toast.show({icon:'success',content:'已清空购物车'})
            clearShopcart({userid:localStorage.getItem('userid')}).then((res)=>{
                shopcartlist({userid:localStorage.getItem('userid')}).then((res)=>{
                    this.setState({
                     list:res.data.list
                    })
                 })
                // window.location.reload()
            })
        }
        
    
    render() {
        return (
            <div className='shopcartheader'>
                <div className='title'>
                    购物车
                </div>
                <div className='header'>
                    <div>cdf会员购</div>
                    <div onClick={()=>{this.handleClear()}}>清空购物车</div>
                </div>
                <div className='choose'>
                   <div className='black'>已满￥200,享超值换购,已选0/1</div>
                   <div className='orange'>立即挑选</div>
                </div>
            </div>
        );
    }
}

export default MyHeader ;